package com.mrzhou.auth.constant;

public interface AuthConstant {

    /* 保存到redis的键前缀 */
    String REDIS_PREFIX_AUTH_CODE = "auth:code:";
    /* 客户端信息 */
    String REDIS_PREFIX_CLIENT_INFO = "client:info:";
    Integer AUTH_CODE_LENGTH = 12; // 授权码的长度
    Long Auth_CODE_TIME_OUT = 30L; // 授权码30秒过期
    /* authCode使用状态: 未使用 */
    int AUTH_CODE_STATUS_NOT_USE = 0;


    // 密码前缀, 必须是{xx}的形式否则会报: There is no PasswordEncoder mapped for the id "null"
    String ENCRYPT = "{mrzhou-cloud}";
    String ENCRYPT_ID = "mrzhou-cloud";
    String CLIENT_ENCRYPT = "{noop}";
    String CLIENT_ENCRYPT_ID = "noop";

    // cloud_client表名称
    String CLIENT_NAME = "cloud_client";

    // cloud_client表字段
    String CLIENT_FILED = "client_id, CONCAT('"+CLIENT_ENCRYPT+"', client_secret) as client_secret, resource_ids, scope, authorized_grant_types, " +
            "web_server_redirect_uri, authorities, access_token_validity, " +
            "refresh_token_validity, additional_information, autoapprove";

    // 查询cloud_client表
    String BASIC_SELECT = "SELECT " + CLIENT_FILED + " FROM " + CLIENT_NAME;

    // 根据client_id查询表中的client信息
    String SELECT_BY_CLIENT_ID = BASIC_SELECT + " WHERE client_id = ?";

    // 根据client_id排序
    String CLIENT_ORDER = BASIC_SELECT + " ORDER BY client_id";

}
